<template>
    <div class="cart">
        <NavBar class="nav-bar">
            <div slot="center">购物车({{cartLength}})</div>
        </NavBar>
        <CartList></CartList>
        <CartButtonBar></CartButtonBar>
    </div>
</template>
<script>
import NavBar from 'components/common/navbar/NavBar'

import CartList from './childComps/CartList'
import CartButtonBar from './childComps/CartButtonBar'

import {mapGetters} from 'vuex'

export default {
    name:'Cart',
    components:{
        NavBar,
        CartList,CartButtonBar
    },
    data() {
        return {
            
        }
    },
    computed: {
        // cartLength(){
        //     return this.$store.getters.cartLength
        // }
        // 第一种用法
        // ...mapGetters({
        //     length:'cartLength',
        //     list:'cartList'
        // })
        // 第二种用法
        ...mapGetters(['cartLength','cartList'])
    },
}
</script>
<style scoped>
.nav-bar{
    background-color:var(--color-tint);
    font-weight: 700;
    color: #fff;
}
</style>